import java.io.*;
import java.util.ArrayList;
import java.util.Collections;

public class ServerMain {
	
	public static void main(String[] args){
		
		String synopsis1 = "In the future, Jake, a paraplegic war veteran, is brought to another planet, Pandora, which is inhabited by the Na'vi, a humanoid race with their own language and culture. Those from Earth find themselves at odds with each other and the local culture.";
		String synopsis2 = "--";
		Tv tv1 = new Tv("Tv Samsung", "HBO", "Avatar", "Science-Fiction", "10:30AM", "13:12PM", synopsis2);
//		Tv tv2 = new Tv("Tv Samsung", "Canal+", "PSG-STB", "sports", "11:00AM", "12:45PM", synopsis1);
		JmDNSService service1 = new JmDNSService(tv1);
//		JmDNSService service2 = new JmDNSService(tv2);
		
		webSocket wsocket = new webSocket();
		int clients = 0;
		ArrayList<Communication> comClients =  new ArrayList<Communication>();
		while(clients < 3){
			wsocket.connect(Constants.PORT);
			
			Communication client = wsocket.accept(tv1);
			System.out.println("New client...");
			client.start();
			comClients.add(client);
			clients++;
		
		}
		for(int i=0;i<comClients.size();i++){
			try{
				comClients.get(i).join();		
			}catch (InterruptedException e){
				
			}
		}
		service1.close();
//		service2.close();
	
	}
	
	
	
	

}
